/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gravity;

import java.util.ArrayList;
import java.util.List;
import processing.core.PApplet;
import processing.core.PVector;

/**
 *
 * @author user
 */
public class SystemSimulator extends PApplet {

    public static final float largeG = 1;
   
    private List<SpaceObject> system;

    @Override
    public void setup() {
        size(1000, 400);
        background(0);
        system = new ArrayList<SpaceObject>();


        SpaceObject earth = new SpaceObject(this, new PVector(0, 0), new PVector(5, 0), new PVector(100, 100), 1, 5);
        SpaceObject sun = new SpaceObject(this, new PVector(0, 0), new PVector(0, 0), new PVector(500, 200), 2500, 10);
        system.add(earth);
        system.add(sun);
    }

    @Override
    public void draw() {
        background(0);
        for (SpaceObject s1 : system) {
            for (SpaceObject s2 : system) {
                if (!s1.equals(s2)) {
                    PVector f = s2.calcGravForce(s1);
                    s1.applyForce(f);
                }
            }
            s1.update();
            s1.display();
        }
    }
}
